import request from '@/utils/request'

export default {
  getActivityList(searchModel) {
    return request({
      url: '/releaseActivity/list',
      method: 'get',
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        activityName: searchModel.activityName,
        activityStatus: searchModel.activityStatus
      }
    })
  },
  addActivity(activity) {
    return request({
      url: '/releaseActivity',
      method: 'post',
      data: activity
    })
  },
  updateActivity(activity) {
    return request({
      url: '/releaseActivity',
      method: 'put',
      data: activity
    })
  },
  deleteActivityById(id) {
    return request({
      url: `/releaseActivity/${id}`,
      method: 'delete'
    });
  },
  saveActivity(activity) {
    if (activity.id == null && activity.id == undefined) {
      return this.addActivity(activity)
    }
    return this.updateActivity(activity)
  },
  getActivityById(id) {
    return request({
      // url: '/releaseActivity/' + id,
      url: `/releaseActivity/${id}`,
      method: 'get'
    })
  },
  collectActivityById(id) {
    return request({
      url: `/collect/collect`,
      method: 'get',
      params: {
        id: id
      }
    })
  },
  getCollectList() {
    return request({
      url: `/collect/getCollectList`,
      method: 'get'
    })
  },
  cancelCollect(id) {
    return request({
      url: `/collect/${id}`,
      method: 'delete'
    });
  }
}
